Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new lint: pub_api_sealed_trait_became_unconditionally_sealed #1166

Conversation

lovelindhoni
Copy link
Contributor

Resolves #1122

@lovelindhoni lovelindhoni changed the title new lint: pub_api_sealed_trait_became_unconditionally_sealed new lint: pub_api_sealed_trait_became_unconditionally_sealed Feb 28, 2025
Comment on lines 50 to 52
error_message: "A public API sealed trait is now unconditionally sealed, preventing all external implementations.
This change impacts related first-party crates (e.g., derive macros or other internal tooling)
that previously could implement the trait using non-public API",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this will get formatted correctly with our RON format. I think it'll end up stored and read as a multi-line string with the exact set of newline and consecutive space characters as exist in this file.

You can verify this by running cargo run -- semver-checks --manifest-path test_crates/pub_api_sealed_trait_became_unconditionally_sealed/new/Cargo.toml --baseline-root test_crates/pub_api_sealed_trait_became_unconditionally_sealed/old/Cargo.toml and seeing whether the error message is printed correctly. I suspect it'll come out hard-wrapped in an unpredictable and undesirable way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the output is rather abnormal. I rewritten that to match other queries

Comment on lines 32 to 40
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please take a look at some of the other lints' queries and try to match the style and formatting of queries. The fact that this query is so dense and has no whitespace means it's quite difficult to read.

This change prevents all external implementations, including from related first-party crates
that might have relied on private API access",
required_update: Major,
lint_level: Deny,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right lint level here?

@lovelindhoni lovelindhoni requested a review from obi1kenobi March 1, 2025 04:23
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

@obi1kenobi obi1kenobi enabled auto-merge (squash) March 1, 2025 14:19
auto-merge was automatically disabled March 1, 2025 16:11

Head branch was pushed to by a user without write access

@obi1kenobi obi1kenobi enabled auto-merge (squash) March 1, 2025 20:43
@obi1kenobi obi1kenobi merged commit 0057293 into obi1kenobi:main Mar 1, 2025
30 of 31 checks passed
@lovelindhoni lovelindhoni deleted the pub-api-sealed-trait-became-unconditionally-sealed branch March 2, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants